package org.jeecg.modules.xl.customerType.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import org.jeecg.modules.xl.customerType.entity.XlCustomerType;
import org.jeecg.modules.xl.customerType.mapper.XlCustomerTypeMapper;
import org.jeecg.modules.xl.customerType.service.IXlCustomerTypeService;
import org.jeecg.modules.xl.customerType.vo.CustomerTreeVO;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 供货渠道
 * @Author: jeecg-boot
 * @Date:   2024-10-27
 * @Version: V1.0
 */
@Service
public class XlCustomerTypeServiceImpl extends ServiceImpl<XlCustomerTypeMapper, XlCustomerType> implements IXlCustomerTypeService {

    @Override
    public List<CustomerTreeVO> listTree(String typeDesc) {
        List<CustomerTreeVO> result = Lists.newArrayList();

        List<XlCustomerType> list = list(Wrappers.lambdaQuery(XlCustomerType.class)
            .like(StringUtils.isNotBlank(typeDesc),XlCustomerType::getTypeDesc, typeDesc)
        );
        int i = 0;
        for (XlCustomerType type : list) {
            result.add(new CustomerTreeVO(type.getTypeCode(),type.getTypeCode(),type.getTypeDesc(),type.getTypeCode(),"0",false, i++, Lists.newArrayList()));
        }
        return result;
    }
}
